package cosc617_blackteam;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author Laura
 * An iterator that iterates through approved comments
 *
 */
public class ApprovedCommentIterator implements Iterator<Comment> {
	private ArrayList<Comment> comments;
	int index;
	public ApprovedCommentIterator(ArrayList<Comment> comments){
		this.comments = comments;
		index = 0;
	}
	@Override
	public boolean hasNext() {
		for (int i = index; i < comments.size(); i++){
			if (comments.get(i).isApproved())
				return true;
			index++;
		}
		return false;
	}

	@Override
	public Comment next() {
		Comment output = comments.get(index);
		index++;
		return output;
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}

}
